const schedule = require('node-schedule');
const mysql = require('mysql')
var connection = mysql.createConnection({
  host: '119.29.24.107',
  user: 'cAuth',
  password: 'Yusup0604',
  database: 'cAuth'
});


schedule.scheduleJob('0 0 0 * * *', async () => {
  let query = 'insert into counter(dict_date, dict_search_count, ocr_count, uyAsr_count, cnAsr_count) values(CURRENT_DATE,0,0,0,0)'
  connection.connect();
  connection.query(query, function (error, results, fields) {
    if (error) throw error;
    console.log('The solution is: ', results);
  });
  connection.end();
})

schedule.scheduleJob('0 1 0 * * *', async () => {
  let query = 'insert into counter(dict_date, dict_search_count, ocr_count, uyAsr_count, cnAsr_count) values(CURRENT_DATE,0,0,0,0)'
  connection.connect();
  connection.query(query, function (error, results, fields) {
    if (error) throw error;
    console.log('The solution is: ', results);
  });
  connection.end();
})
